<?php

class Default_Model_DbTable_User extends Zend_Db_Table_Abstract
{

    protected $_name = 'user';
    //add user
    public function AddUser($UName,$Pass,$Email,$Gender,$Dob,$Addr,$Stt){
    	$UData = array("USERNAME"=>$UName,"PASSWORD"=>$Pass,"EMAIL"=>$Email
    			,"GENDER"=>$Gender,"DOB"=>$Dob,"ADDRESS"=>$Addr,"STATUS"=>$Stt);
    	$this->insert($UData);
    }
    //update user
    public function UpdateUser($Id,$UName,$Pass,$Email,$Gender,$Dob,$Addr,$Stt){
    	$UData = array("USERNAME"=>$UName,"PASSWORD"=>$Pass,"EMAIL"=>$Email
    			,"GENDER"=>$Gender,"DOB"=>$Dob,"ADDRESS"=>$Addr,"STATUS"=>$Stt);
    	$this->update($UData,"ID = $Id");
    }
    //del user
    public function DelUser($Id){
    	return $this->delete("ID = $Id");
    }
    //Get all user
    public function GetAll(){
    	return $user = $this->fetchAll();
    }
    //Get user by id
    public function GetByID($Id){
    	return $user = $this->fetchRow("ID = $Id");
    }
    //get user by name
    public function GetByName($Name){
    	return $user = $this->fetchRow("USERNAME = '$Name'");
    }
    //get user by name and pass
    public function GetUNamePass($UName,$Pass){
    	return $this->fetchRow("USERNAME = $UName And PASSWORD = $Pass");
    }
    //change status
    public function Active($id){
    	$status = $this->fetchRow("ID = $id")->toArray();
    	if($status["STATUS"]==1){
    		$this->update(array("STATUS"=>"0"), "ID = $id");
    	}
    	else{
    		$this->update(array("STATUS"=>"1"), "ID = $id");
    	}
    }
}
